package com.houweishi.module.report.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.report.domain.BizWorkReport;
import com.houweishi.module.report.service.IBizWorkReportService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 员工工作报告Controller
 * 
 * @author houweishi
 * @date 2023-02-21
 */
@RestController
@RequestMapping("/module/report")
public class BizWorkReportController extends BaseController
{
    @Autowired
    private IBizWorkReportService bizWorkReportService;

    /**
     * 查询员工工作报告列表
     */
    @PreAuthorize("@ss.hasPermi('module:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizWorkReport bizWorkReport)
    {
        startPage();
        List<BizWorkReport> list = bizWorkReportService.selectBizWorkReportList(bizWorkReport);
        return getDataTable(list);
    }

    /**
     * 导出员工工作报告列表
     */
    @PreAuthorize("@ss.hasPermi('module:report:export')")
    @Log(title = "员工工作报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizWorkReport bizWorkReport)
    {
        List<BizWorkReport> list = bizWorkReportService.selectBizWorkReportList(bizWorkReport);
        ExcelUtil<BizWorkReport> util = new ExcelUtil<BizWorkReport>(BizWorkReport.class);
        util.exportExcel(response, list, "员工工作报告数据");
    }

    /**
     * 获取员工工作报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:report:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizWorkReportService.selectBizWorkReportById(id));
    }

    /**
     * 新增员工工作报告
     */
    @PreAuthorize("@ss.hasPermi('module:report:add')")
    @Log(title = "员工工作报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizWorkReport bizWorkReport)
    {
        return toAjax(bizWorkReportService.insertBizWorkReport(bizWorkReport));
    }

    /**
     * 修改员工工作报告
     */
    @PreAuthorize("@ss.hasPermi('module:report:edit')")
    @Log(title = "员工工作报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizWorkReport bizWorkReport)
    {
        return toAjax(bizWorkReportService.updateBizWorkReport(bizWorkReport));
    }

    /**
     * 删除员工工作报告
     */
    @PreAuthorize("@ss.hasPermi('module:report:remove')")
    @Log(title = "员工工作报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizWorkReportService.deleteBizWorkReportByIds(ids));
    }
}
